package com.alibaba.cloud.base.business.dict.controller;

import com.alibaba.cloud.base.business.dict.domain.BasDict;
import com.alibaba.cloud.base.business.dict.service.BasDictService;
import com.alibaba.framework.aop.log.LogWrite;
import com.alibaba.framework.domain.ResponseWrapper;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Tag(name = "基础字典")
@RestController
@RequestMapping("/dict")
public class BasDictController {

    private static final Logger LOGGER = LoggerFactory.getLogger(BasDictController.class);

    @Resource
    private BasDictService basDictService;

    @LogWrite(value = "查询医嘱项目列表")
    @GetMapping("/getAll")
    public ResponseWrapper getAll() {

        List<BasDict> basOrderList = basDictService.getAll();
        return ResponseWrapper.Success(basOrderList);
    }

    @LogWrite(value = "根据类型查询医嘱项目列表")
    @GetMapping("/getDictByType")
    public ResponseWrapper getDictByType(@RequestParam("dictType") String dictType) {

        List<BasDict> basOrderList = basDictService.getDictByType(dictType);
        return ResponseWrapper.Success(basOrderList);
    }

    @LogWrite(value = "新增医嘱项目")
    @PostMapping("/save")
    public ResponseWrapper save(@RequestBody BasDict basDict) {

        basDictService.save(basDict);
        return ResponseWrapper.Success();
    }

    @LogWrite(value = "修改医嘱项目")
    @PostMapping("/update")
    public ResponseWrapper update(@RequestBody BasDict basDict) {

        basDictService.update(basDict);
        return ResponseWrapper.Success();
    }
}
